﻿<UserControl 
    x:Class="Imagin.Controls.Extended.DualColorChip"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:local="clr-namespace:Imagin.Controls.Extended"
    xmlns:Controls.Common="clr-namespace:Imagin.Controls.Common;assembly=Imagin.Controls.Common"
    xmlns:Common.Data.Converters="clr-namespace:Imagin.Common.Data.Converters;assembly=Imagin.Common"
    mc:Ignorable="d"
    x:Name="PART_DualColorChip">
    <UserControl.Resources>
        <Common.Data.Converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter"/>
        
        <DrawingBrush x:Key="SwitchBrush" Viewbox="0,0,11.381,12.011" ViewboxUnits="Absolute"  Stretch="Uniform">
            <DrawingBrush.Drawing>
                <DrawingGroup>
                    <GeometryDrawing Brush="#FF231F20" Geometry="M3.45,5.3119929 L-3.0517605E-06,2.6559988 3.45,4.6386617E-06 z"/>
                    <DrawingGroup>
                        <DrawingGroup.Transform>
                            <MatrixTransform Matrix="1,0,0,1,6.069,8.561"/>
                        </DrawingGroup.Transform>
                        <GeometryDrawing Brush="#FF231F20" Geometry="M5.3120054,0 L2.6560036,3.4499878 1.8798841E-06,0 z"/>
                    </DrawingGroup>
                    <DrawingGroup>
                        <DrawingGroup.Transform>
                            <MatrixTransform Matrix="1,0,0,1,2.009,2.1"/>
                        </DrawingGroup.Transform>
                        <GeometryDrawing Geometry="M6.5110028,6.5119882 C6.5110028,3.1890015 3.8230035,0.50001216 0.50000435,0.50001216">
                            <GeometryDrawing.Pen>
                                <Pen Brush="#FF231F20" DashCap="Flat" EndLineCap="Flat" LineJoin="Miter" MiterLimit="10" StartLineCap="Flat" Thickness="1"/>
                            </GeometryDrawing.Pen>
                        </GeometryDrawing>
                    </DrawingGroup>
                </DrawingGroup>
            </DrawingBrush.Drawing>
        </DrawingBrush>
    </UserControl.Resources>
    <Grid DataContext="{Binding ElementName=PART_DualColorChip}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <Grid 
            Background="Transparent"
            ToolTip="{Binding ResetToolTip}">
            <Controls.Common:CheckerBoard 
                Cursor="Hand" 
                BorderThickness="1"
                BorderBrush="Black"
                Margin="5,5,0,0"
                CheckerForeground="LightGray"
                HorizontalAlignment="Left" 
                VerticalAlignment="Top" 
                PreviewMouseDown="OnDefaultMouseDown">
                <Rectangle 
                    Width="10" 
                    Height="10" 
                    Fill="{Binding DefaultBackground, Converter={StaticResource ColorToSolidColorBrushConverter}}"/>
            </Controls.Common:CheckerBoard>
            <Controls.Common:CheckerBoard 
                Cursor="Hand" 
                BorderThickness="1"
                BorderBrush="Black"
                CheckerForeground="LightGray"
                HorizontalAlignment="Left" 
                VerticalAlignment="Top" 
                PreviewMouseDown="OnDefaultMouseDown" >
                <Rectangle
                    Width="10" 
                    Height="10" 
                    Fill="{Binding DefaultForeground, Converter={StaticResource ColorToSolidColorBrushConverter}}"/>
            </Controls.Common:CheckerBoard>
        </Grid>
        <Grid 
            Grid.Row="1" 
            Margin="0,5,0,0">
            <local:ColorChip 
                HorizontalAlignment="Left"
                Margin="10,10,0,0" 
                VerticalAlignment="Top"
                Height="22" 
                Width="22" 
                ToolTip="{Binding BackgroundToolTip}"
                Color="{Binding BackgroundColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
            <local:ColorChip 
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Height="22" 
                Width="22" 
                ToolTip="{Binding ForegroundToolTip}"
                Color="{Binding ForegroundColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
            
            <Rectangle
                Cursor="Hand" 
                Fill="{StaticResource SwitchBrush}"
                Height="15" 
                HorizontalAlignment="Left" 
                Margin="20,-10,0,0" 
                PreviewMouseDown="OnSwitchMouseDown" 
                Stroke="{x:Null}" 
                ToolTip="{Binding SwitchToolTip}"
                VerticalAlignment="Top" 
                Width="16"/>
        </Grid>
    </Grid>
</UserControl>
